/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: user
 * Date: 2023-10-15
 * Time: 18:44
 */
import binarysearchtree.BinarySearchTree;
import demo1.HashBuck;

import java.util.*;


public class test01 {

    public static void main(String[] args) {
        HashBuck hashBuck = new HashBuck();
        hashBuck.put(1,11);
        hashBuck.put(2,22);
        hashBuck.put(19,99);
        hashBuck.put(5,55);
        hashBuck.put(6,66);
        hashBuck.put(11,66);
        hashBuck.put(7,77);
        hashBuck.put(8,888);
        hashBuck.put(21,2111);

        System.out.println(hashBuck.get(9));
    }

    public static void main3(String[] args) {
        Set<String> set = new TreeSet<>();
        set.add("sunny");
        set.add("hello");
        set.add("the");
        set.add("the");

        System.out.println(set);

        Iterator<String> it = set.iterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }
    }

    public static void main2(String[] args) {
        TreeMap<String,Integer> map = new TreeMap<>();//查找的复杂度O(logN)
        map.put("sunny",3);
        map.put("the",5);
        map.put("hello",2);
        map.put("hello",21);
        //通过key获取val值
        Integer val = map.getOrDefault("the2",99999);
        System.out.println(val);


        Set<String> set = map.keySet();
        System.out.println(set);

        Set<Map.Entry<String,Integer>> entrySet = map.entrySet();
        System.out.println("===================");
        for(Map.Entry<String,Integer> entry : entrySet) {
            System.out.println("key: "+entry.getKey() +" value: "+entry.getValue());
        }

        //Map<String,Integer> map2 = new HashMap<>();//查找的复杂度O(1)  哈希表-》 数组+链表+红黑树组成的

    }

    public static void main1(String[] args) {
        BinarySearchTree binarySearchTree = new BinarySearchTree();
        int[] array = {5,12,3,2,11,15};
        for (int i = 0; i < array.length; i++) {
            binarySearchTree.insert(array[i]);
        }
        binarySearchTree.remove(12);

        System.out.println("=====");
    }
}
